#include "client.h"

int transfile(int sockfd, char* pathname){
    //获取接收方的偏移量
    current_statu = 2;
    off_t offset;
    recv(sockfd,&offset,sizeof(off_t),0);
    //打开要发送的文件并发送文件大小给
    int fd = open(pathname,O_RDWR);
    struct stat statbuf;
    fstat (fd,&statbuf);
    filesize = statbuf.st_size;
    send(sockfd,&filesize,sizeof(off_t),MSG_NOSIGNAL);
    sleep(2);
    current_statu = 2;
    lseek(fd,offset,SEEK_SET);
    sendfile(sockfd,fd,NULL,filesize - offset);
    close(fd);
    current_statu = 0;
    return 0;
}


